﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bids.Core.Infrastructure;
using Telerik.OpenAccess.Metadata;
using Telerik.OpenAccess.Metadata.Fluent;

namespace Bids.Core.DomainObjects
{
    [Serializable]
    public class DesignerCase : IEntity
    {
        public DesignerCase()
        {
            this.CreateTime = DateTime.Now;
        }
        /// <summary>
        /// 
        /// </summary>
        public virtual int ID { set; get; }
        /// <summary>
        /// 用户Id
        /// </summary>
        public virtual int UserId { set; get; }
        /// <summary>
        /// 案例图片
        /// </summary>
        public virtual string Img { set; get; }
        /// <summary>
        /// 添加时间
        /// </summary>
        public virtual DateTime CreateTime { set; get; }
        public virtual User User { get; set; }
        public static MappingConfiguration<DesignerCase> CreateConfiguration()
        {
            var threadMapping = new MappingConfiguration<DesignerCase>();
            threadMapping.MapType(t => new
            {
                t.ID,
                t.UserId,
                t.Img,
                t.CreateTime
            }).ToTable("DesignerCase");
            threadMapping.HasProperty(t => t.ID).IsIdentity(KeyGenerator.Autoinc);
            threadMapping.HasAssociation(t => t.User).WithOpposite(d => d.DesignerCases).HasConstraint((t, d) => t.UserId == d.ID);
            return threadMapping;
        }
    }
}
